import homeStore from "../../../store/home_store"


Page({

  /**
   * 页面的初始数据
   */
  data: {
    results: {},
    id: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    const { id } = options
    this.setData({ id })
    homeStore.dispatch('fetchDetailsAction', id)
    homeStore.onState('details', this.handleDetailsValue)
  },

  // 数据赋值
  handleDetailsValue(value) {
    this.setData({ results: value })
  },

  // 页面卸载
  onUnload() {
    homeStore.offState('details', this.handleDetailsValue)
  },

  // 方法
  handleCall() {
    wx.makePhoneCall({
      phoneNumber: '10086' //仅为示例，并非真实的电话号码
    })
  },
  handleReservation() {
    wx.navigateTo({
      url: `/homepackage/pages/reservation-service/reservation-service?id=${this.data.id}`
    })
  }
})